<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>11.总结一下原型链</title>
</head>

<body>
  <script>

    // 原型链
    let arr = [];
    console.log(arr.__proto__ == Array.prototype);//true
    console.log(Array.prototype.__proto__ == Object.prototype);//true
    console.log(arr.__proto__.__proto__ == Object.prototype);//true

    //设置原型，达到继承的效果
    let a = { name: 'a' };
    let c = { name: 'c' };
    let b = {
      name: 'b',
      show () {
        console.log(this.name);
      },
      view () {
        console.log('view method');
      }
    };
    // 设置原型
    Object.setPrototypeOf(a, b);
    Object.setPrototypeOf(c, b);
    //this 指向实例化它的对象 不回指向 原型 b
    a.show();//a
    c.show();//c
    a.view();//view method
    c.view();//view method



  </script>
</body>

</html>